package com.jinarusha.shareprayers.Model;

import java.util.ArrayList;

import android.text.format.Time;

public abstract class AList {

	protected String categoryTitle;
	protected ArrayList<AListItem> listItemArrayList;
	protected ArrayList<String> sharedGroupIDArrayList;
	protected ArrayList<String> sharedIndividualIDArrayList;
	protected Time lastUpdated;
	protected Time createdTime;

	public AList() {
		categoryTitle = "";

		sharedGroupIDArrayList = new ArrayList<String>();
		sharedIndividualIDArrayList = new ArrayList<String>();

		// get current time
		createdTime = new Time();
		createdTime.setToNow();
		lastUpdated = new Time();
		lastUpdated.setToNow();
	}

	public AList(String cat_title, ArrayList<String> sharedgrouplist,
			ArrayList<String> sharedindividuallist) {
		this();
		if (cat_title != null && !cat_title.equals(""))
			categoryTitle = cat_title;
		if (sharedgrouplist != null)
			sharedGroupIDArrayList = sharedgrouplist;
		if (sharedindividuallist != null)
			sharedIndividualIDArrayList = sharedindividuallist;
	}

	public String getCategoryTitle() {
		return categoryTitle;
	}

	public void setCategoryTitle(String title) {
		this.categoryTitle = title;
	}

	public void setLastUpdated() {
		this.lastUpdated.setToNow();
	}

	public Boolean addGroupID(String groupid) {
		return sharedGroupIDArrayList.add(groupid);
	}

	public Boolean removeGroupID(String groupid) {
		return sharedGroupIDArrayList.remove(groupid);
	}

	public Boolean hasGroupID(String groupid) {

		return sharedGroupIDArrayList.contains(groupid);
	}

	public Boolean addIndividualID(String id) {
		return sharedIndividualIDArrayList.add(id);
	}

	public Boolean removeIndividualID(String id) {
		return sharedIndividualIDArrayList.remove(id);
	}

	public Boolean hasID(String id) {

		return sharedIndividualIDArrayList.contains(id);
	}

	public Time getLastUpdated() {
		return lastUpdated;
	}
}
